package com.demo.math.app;

import com.demo.math.domain.MathStrategy;
import com.demo.math.equationImpl.*;

import java.util.HashMap;
import java.util.Map;

public class QuestionBankContext {

    public static final String ADD_SUB_2 = "ADD_SUB_2";
    public static final String ADD_SUB_3 = "ADD_SUB_3";
    public static final String JUDGE = "JUDGE";
    public static final String FILL_PLUS_MIN_2 = "FILL_PLUS_MIN_2";
    public static final String FILL_PLUS_MIN_3 = "FILL_PLUS_MIN_3";

    private static final Map<String, MathStrategy> strategyMap = new HashMap<>();

    {
        strategyMap.put(ADD_SUB_2, new AddSub2MathStrategy());
        strategyMap.put(ADD_SUB_3, new AddSub3MathStrategy());
        strategyMap.put(JUDGE, new JudgeMathStrategy());
        strategyMap.put(FILL_PLUS_MIN_2, new FillPlusMin2MathStrategy());
        strategyMap.put(FILL_PLUS_MIN_3, new FillPlusMin3MathStrategy());
    }

    public String math(String type, int range) {
        return strategyMap.get(type).math(range);
    }

}
